home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / sysdeps / generic / sigset.h < prev    next >
C/C++ Source or Header  |  1994-05-21  |  3KB  |  73 lines

  1. /* __sig_atomic_t, __sigset_t, and related definitions.  Generic/BSD version.
  2. Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4.  
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version.
  9.  
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with the GNU C Library; see the file COPYING.LIB.  If
  17. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  18. Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef    _SIGSET_H_types
  21. #define    _SIGSET_H_types    1
  22.  
  23. typedef int __sig_atomic_t;
  24.  
  25. /* A `sigset_t' has a bit for each signal.  */
  26. typedef unsigned long int __sigset_t;
  27.  
  28. #endif
  29.  
  30.  
  31. /* We only want to define these functions if <signal.h> was actually
  32.    included; otherwise we were included just to define the types.  Since we
  33.    are namespace-clean, it wouldn't hurt to define extra macros.  But
  34.    trouble can be caused by functions being defined (e.g., any global
  35.    register vars declared later will cause compilation errors).  */
  36.  
  37. #if !defined (_SIGSET_H_fns) && defined (_SIGNAL_H)
  38. #define _SIGSET_H_fns 1
  39.  
  40. /* Return a mask that includes SIG only.  The cast to `sigset_t' avoids
  41.    overflow if `sigset_t' is wider than `int'.  */
  42. #define    __sigmask(sig)    (((__sigset_t) 1) << ((sig) - 1))
  43.  
  44. #define    __sigemptyset(set)    ((*(set) = 0L), 0)
  45. #define    __sigfillset(set)    ((*(set) = -1L), 0)
  46.  
  47. /* These functions must check for a bogus signal number.  We detect it by a
  48.    zero sigmask, since a number too low or too high will have shifted the 1
  49.    off the high end of the mask.  If we find an error, we punt to the
  50.    real-function version of the same function, so as to avoid referring to
  51.    `errno' in this file (sigh).  */
  52.  
  53. #ifndef _EXTERN_INLINE
  54. #define _EXTERN_INLINE extern __inline
  55. #endif
  56. #define __SIGSETFN(NAME, BODY, CONST)                          \
  57.   _EXTERN_INLINE int                                  \
  58.   __##NAME (CONST __sigset_t *__set, int __sig)                      \
  59.   {                                          \
  60.     extern int NAME (CONST __sigset_t *, int);                      \
  61.     __sigset_t __mask = __sigmask (__sig);                      \
  62.     return __mask ? (BODY) : (NAME) (__set, __sig);                  \
  63.   }
  64.  
  65. __SIGSETFN (sigismember, (*__set & __mask) ? 1 : 0, __const)
  66. __SIGSETFN (sigaddset, ((*__set |= __mask), 0), )
  67. __SIGSETFN (sigdelset, ((*__set &= ~__mask), 0), )
  68.  
  69. #undef __SIGSETFN
  70.  
  71.  
  72. #endif /* ! _SIGSET_H_fns.  */
  73.